using System;
using System.Web.Mvc;
using NHCourse.Domain;
using NHCourse.Models;

namespace NHCourse.Controllers
{
   public class UsersController : AppController
   {
      public ActionResult Index()
      {
         return RedirectToAction("index", "home");
      }

      public ActionResult Show(int id)
      {
         var user = GetDummyUser(id);

         return View(new UsersShowModel(user));
      }

      [HttpPost]
      public ActionResult Show(UsersShowModel model)
      {
         if (!ModelState.IsValid)
            return View(model);

         return RedirectTo<HomeController>(c => c.Index());
      }

      private User GetDummyUser(int id)
      {
         return new User
            {
               Id = id,
               DisplayName = "Dummy User",
               WebsiteUrl = "http://dummyuser.us",
               Reputation = 1000
            };
      }
   }
}